package com.wx.app.app;

import android.app.Application;

import com.wx.app.dao.DaoHelper;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.concurrent.TimeUnit;

import okio.Buffer;


/**
 * Created by Administrator on 2016/5/10.
 */
public class MyApplication extends Application {

    private static MyApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        DaoHelper.getInstance().setupDatabase(instance);
        initOkHttp();
    }

    private void initOkHttp() {

        //这里可以设置自签名证书
        OkHttpUtils.getInstance().setCertificates(new Buffer()
                .inputStream());
        OkHttpUtils.getInstance().debug("OkHttpUtils").setConnectTimeout(100000, TimeUnit.MILLISECONDS);
        //使用https，但是默认信任全部证书
        OkHttpUtils.getInstance().setCertificates();
    }


    public static MyApplication getInstance() {
        return instance;
    }

}
